<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport"
  content="width=device-width, initial-scale=1.0, minimum-scale=1,maximum-scale=1,user-scalable=no">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title data-ch="恐龙探险" data-en="Dinosaur Adventure" class="document_title">恐龙探险</title>
 <script src="js/jquery-3.3.1.min.js"></script>
 <script src="js/common.js"></script>
 <script src="js/layer.js"></script>
 <script src="js/rem.js"></script>
 <script type="text/javascript">
  isLogin();
 </script>
 <link rel="stylesheet" href="css/common.css">
 <link rel="stylesheet" type="text/css" href="css/css.css">
</head>
<body>
<!--头部-->
<div class="jui_top_bar">
    <a class="jui_top_left" href="javascript:history.back(-1)"><img src="icons/back.png"></a>
    <div class="jui_top_middle" data-ch="更改密码" data-en="Change password">更改密码</div>
</div>
<!--头部end--> 
<!--主体-->
<form action="">
<div class="jui_main">
     <div class="jui_pad_12">
          <div class="bg_light_black jui_bor_rad_15 jui_pad_20">
                <div class="col_fff jui_pad_b5" data-ch="当前密码" data-en="Current password">当前密码</div>
                <input id="oldPass" class="jui_bor_rad_5 smrz_input" type="password" data-ch="请输入当前密码" data-en="Please enter current password" value=""
                 placeholder="请输入当前密码">
                <div class="jui_h16"></div>
                <div class="col_fff jui_pad_b5" data-ch="新密码" data-en="New password">新密码</div>
                <input id="newPass" class="jui_bor_rad_5 smrz_input" type="password" data-ch="请输入新密码" data-en="Please enter new password" value="" placeholder="请输入新密码">
                <div class="jui_h16"></div>
                <div class="col_fff jui_pad_b5" data-ch="确认新密码" data-en="Confirm new password">确认新密码</div>
                <input id="surePass" class="jui_bor_rad_5 smrz_input" type="password" data-ch="请确认新密码" data-en="Please confirm new password" value="" placeholder="请确认新密码">
                <div class="jui_h20"></div>
                <div class="ziliao_btn" data-ch="确认" data-en="Confirm">确认</div>
          </div>
     </div>
</div>
</form>
<!--主体end-->

<script>
 $(document).ready(function(){
 var language_type = localStorage.getItem("language_type");
 $(".ziliao_btn").click(function(){
  console.log(!$("#oldPass").val())
  if(!$("#oldPass").val()){
  box_timer(language_type == 1 ? '请输入旧密码' : 'Please enter the old password');
  } else if(!$("#newPass").val()){
  box_timer(language_type == 1 ? '请输入新密码' : 'Please enter the new password');
  } else if($("#newPass").val() != $("#surePass").val()){
  box_timer(language_type == 1 ? '两次密码输入不一致' : 'Password did not match, Please try again');
  } else {
   var data = {
    uid: localStorage.getItem("u_id"),
    token: localStorage.getItem("token"),
    language_type: language_type,
    old_pwd: $("#oldPass").val(),
    m_pwd1: $("#newPass").val(),
    m_pwd2: $("#surePass").val(),
    p_type: 1
   }
   $.ajax({
    type: 'post',
    url: baseURL + '/index.php?m=user&c=edit_pwd',
    data: data,
    success: function success(data){
    data = JSON.parse(data);
     is_login(data);
     box_timer(data.msg)
     if(data.code == 1){
      setTimeout(function(){
       window.history.go(-1) // 返回上一页
      },1500)
     }
    }
   })
  }
 })

 language();
 documentName()
 });

</script>
</body>
</html>
